﻿<Window x:Class="Conmigo.Widgets.AddressBook"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell"
    xmlns:widgets="clr-namespace:Conmigo.Widgets"
    xmlns:std="clr-namespace:Standard"
    Background="Transparent"
    Title="Contacts">
  <Window.Resources>
    <!-- Converters -->
    <widgets:ContactUserTileToImageConverter x:Key="UserTileConverter"/>
    <widgets:MultiplierConverter x:Key="multiplyBy"/>

    <!-- DataTemplate for displaying Contacts in the listbox.
         This is intended to look similar to the tile view in Vista's Explorer -->
    <DataTemplate x:Key="ContactItemTemplate">
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="Auto"/>
          <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
          <RowDefinition Height="*"/>
          <RowDefinition Height="*"/>
          <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Image Grid.Column="0" Grid.Row="0" Grid.RowSpan="3" Source="{Binding Converter={StaticResource UserTileConverter}}"/>
        <TextBlock Grid.Column="2" Grid.Row="0" Text="{Binding Path=Names.Default.FormattedName}"/>
        <TextBlock Grid.Column="2" Grid.Row="1"  Text="{Binding Path=EmailAddresses.Default.Address}"/>
        <TextBlock Grid.Column="2" Grid.Row="2" Text="{Binding Path=PhoneNumbers[Business].Number}"/>
      </Grid>
    </DataTemplate>

    <!-- Bluebar menu item style -->
    <Style TargetType="{x:Type MenuItem}">
      <Setter Property="Foreground" Value="White"/>
      <Setter Property="Margin" Value="3"/>
    </Style>

    <Style TargetType="{x:Type Menu}">
      <Setter Property="Background">
        <Setter.Value>
          <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
            <GradientStop Color="#4B90Df" Offset="0" />
            <GradientStop Color="#295591" Offset=".5" />
            <GradientStop Color="#183D76" Offset="0.51" />
            <GradientStop Color="#325F9E" Offset="1" />
          </LinearGradientBrush>
        </Setter.Value>
      </Setter>
    </Style>

    <Style TargetType="{x:Type Button}" x:Key="captionButtonStyle">
      <Setter Property="Visibility" Value="Hidden"/>
    </Style>
  </Window.Resources>

    <DockPanel x:Name="_NavigationRoot" Margin="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=(shell:WindowChrome.WindowChrome).ResizeBorderThickness}">
    <!-- Split the chrome area into its own panel -->
    <Grid DockPanel.Dock="Top" x:Name="_Caption">

      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="*"/>
      </Grid.ColumnDefinitions>

      <DockPanel Grid.Row="1" Grid.Column="1">
        <DockPanel.Background>
          <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
            <GradientStop Color="#4B90Df" Offset="0" />
            <GradientStop Color="#295591" Offset=".5" />
            <GradientStop Color="#183D76" Offset="0.51" />
            <GradientStop Color="#325F9E" Offset="1" />
          </LinearGradientBrush>
        </DockPanel.Background>
        <DockPanel DockPanel.Dock="Right">
          <TextBlock DockPanel.Dock="Left" Foreground="White" VerticalAlignment="Center" Margin="2">
          <Italic>
            Search:
          </Italic>
          </TextBlock>
          <TextBox DockPanel.Dock="Right" Width="150" TextChanged="_FilterWordwheel" x:Name="_wordwheel" Margin="2"/>
        </DockPanel>
        <Menu DockPanel.Dock="Left">
          <MenuItem Header="_New Contact" Name="_newContactButton" Click="_OnNewContact"/>
          <MenuItem Header="_Delete" Name="_deleteContactButton" Click="_OnDelete"/>
          <MenuItem Header="_Import">
            <MenuItem Foreground="Black" Header="Import from _vCard" Name="_importButton" Click="_OnImportVcf"/>
          </MenuItem>
          <MenuItem Header="E_xport">
            <MenuItem Foreground="Black" Header="Export to _vCard" Name="_exportButton" Click="_OnExportVcf"/>
          </MenuItem>
        </Menu>
      </DockPanel>
    </Grid>

    <!-- Contact list takes up the rest of the available space -->
    <ListBox x:Name="_contactPanel"
             MouseDoubleClick="_OpenContact"
             ScrollViewer.HorizontalScrollBarVisibility="Disabled"
             ItemTemplate="{StaticResource ContactItemTemplate}">
      <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
          <widgets:AnimatingTilePanel IsItemsHost="True" ItemHeight="64" ItemWidth="256"/>
        </ItemsPanelTemplate>
      </ListBox.ItemsPanel>
    </ListBox>
  </DockPanel>
</Window>
